package com.caiyi.financial.nirvana.sms.controller;

import com.caiyi.financial.nirvana.sms.entity.SmsKeyword;
import com.caiyi.financial.nirvana.sms.querybean.QueryKeywordBean;
import com.caiyi.financial.nirvana.sms.service.SmsKeywordService;
import com.youyu.common.api.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "关键词管理")
@CrossOrigin
@RestController
@RequestMapping("sms/admin/keyword")
public class KeywordController {

    @Autowired
    private SmsKeywordService keywordService;

    @ApiOperation(value = "添加Keyword详情", notes = "添加Keyword详情描述")
    @ApiImplicitParam(name = "smsKeyword", value = "敏感词", required = true, dataType = "SmsKeyword")
    @PostMapping("/addKeyword")
    public Result addKeyword(@RequestBody SmsKeyword smsKeyword) {
        return Result.ok(keywordService.addKeyword(smsKeyword));
    }

    @ApiOperation(value = "删除Keyword详情", notes = "删除Keyword")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "敏感词id", dataType = "int", paramType = "query", required = true)})
    @PostMapping("/deleteKeyword")
    public Result deleteKeyword(Integer id) {
        return Result.ok(keywordService.deleteKeyword(id));
    }

    @ApiOperation(value = "更新Keyword详情", notes = "更新Keyword")
    @ApiImplicitParam(name = "smsKeyword", value = "敏感词", required = true, dataType = "SmsKeyword")
    @PostMapping("/updateKeyword")
    public Result updateKeyword(@RequestBody SmsKeyword smsKeyword) {
        return Result.ok(keywordService.updateKeyword(smsKeyword));
    }


    @ApiOperation(value = "根据params查找Keyword详情", notes = "根据params查找Keyword详情描述")
    @ApiImplicitParams({@ApiImplicitParam(name = "bean", value = "查找敏感词参数", dataType = "QueryKeywordBean", paramType = "QueryKeywordBean"),

    })
    @PostMapping("/getKeywordByParams")
    public Result getKeywordByParams(@RequestBody QueryKeywordBean bean) {
        return Result.ok(keywordService.getKeywordByParams(bean));
    }
}
